package arraylist;

import java.util.ArrayList;
import java.util.Scanner;

/**
 * 2024/5/14 开发功能,商家菜品功能 14：20
 */
public class Operataor {
    //1.定义一个ArrayList集合对象，负责存储对象信息
    private ArrayList<Food> food=new ArrayList();
    
    //2.开发功能,商家菜品功能
    public void addFood(){
        //3.创建一个菜品对象
        Food f = new Food();
        
        //4.录入到菜品信息进去
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入菜品的名称");
        String name = sc.next();
        f.setName(name);
        
        System.out.println("请输入菜品的价格");
        double  price = sc.nextInt();
        f.setPrice(price);

        System.out.println("请输入菜品的信息");
        String desc=sc.next();
        f.setDesc(desc);

        //5.把菜品信息存入到集合中
         food.add(f);
         System.out.println("上架成功");
         
      
    }

    //6.展示菜品
    public void  showFoods(){
        if(food.size()==0){
            System.out.println("什么菜品都没有,请上架商品");
            return;
        }
        for (int i = 0; i < food.size(); i++) {
            Food food1 = food.get(i);
           System.out.println(food1.getName());
           System.out.println(food1.getPrice());
           System.out.println(food1.getDesc());
        }
    }

    //7.负责展示操作界面
   public void start(){
       System.out.println("请选择功能");
       System.out.println("1.上架商品");
       System.out.println("2.展示菜品");
       System.out.println("3.退出");
       Scanner sc = new Scanner(System.in);
       System.out.println("请选择您的操作");
       String next = sc.next();
       switch (next){
           case "1":
               addFood();
               break;
           case "2":
               showFoods();
               break;
           case "3":
               System.out.println("下次再来");
               return;
           default:
               System.out.println("您输入的命令不存在");
       }
   }

  
}
